<script type="text/javascript">
// SAVE NOTES - sends data to trigger's href
$("#notes_trigger").click(function(){  
    url = "<?=site_url('admin/insiders/update_crm')?>";
    notes = $("#notes").val();
    id = '<?=$item['id_Users']?>';
    orig_str = $("#notes_trigger").text();
    $.post(url,
        { notes : notes, id : id },
        function(data) {
            $("#notes_trigger").text(data).delay(500).slideUp("normal", function(){$(this).text(orig_str)});
        },"html");
    return false; 
});   

$("#notes").keypress(function(){ 
    $("#notes_trigger").slideDown();
});

$("#notes_trigger").hide();

</script>



<div class="nav_col">

    <div style="display:block; float:left; margin-bottom:10px">
        <span style="font-size:10px"><b>Member since:</b>
            <?=date("d/m/Y",strtotime($item['DateJoined_UsersDetails']))?>
        </span>
    </div>

    <div style="display:block; float:left; margin-bottom:10px">
        <span style="font-size:10px"><b>Last login:</b>
            <?=date("d/m/Y",strtotime($item['LastLogin_UsersDetails']))?>
        </span>
    </div>

    <div style="display:block; float:left; margin-bottom:10px">
        <span style="font-size:10px"><b>Number of logins:</b>
        <?=$item['NumberLogins_UsersDetails']?>
        </span>
    </div>

    <div style="display:block; float:left; margin-bottom:10px">
        <span style="font-size:10px"><b>Mailing list member:</b>
        <?=($item['MailingList_UsersDetails'] == 1) ? "Yes" : "No" ?>
        </span>
    </div>

    <div class="buttons" style="margin-bottom:40px">

        <!--
        <a href="<?=site_url('admin/insiders/edit/'.$item['id_Users'])?>" class="button">edit</a>
        -->

        <? if ($item['Active_Users'] == 1){ ?>            
        <a href="<?=site_url('admin/insiders/deactivate/'.$item['id_Users'])?>" class="button">deactivate</a>
        <? } else { ?> 
        <a href="<?=site_url('admin/insiders/activate/'.$item['id_Users'])?>" class="button">activate</a>
        <? } ?>
        
        <a href="<?=site_url('admin/insiders/remove/'.$item['id_Users'])?>" class="button">delete</a>

        <? if ($item['Active_Users']!=1){ ?>
            <div class="preview_inactive">This user was deactivated on:<br /><?=format_date($item['DateDeactivated_UsersDetails'])?></div>
        <? } ?>

    </div>

    <div style="font-size: 12px; line-height:12px; margin-bottom:5px; color:#999; font-weight:bold;">Notes:</div>
    <a href="#" id="notes_trigger" class="button" style="width:150px; text-align:center;">click to save</a>
    <textarea id="notes" style="height:200px; width:150px; padding:5px; border:1px dashed #CCC; background-color:#EEE; font-size:10px; line-height:13px; color:#333; font-style:italic"><?=@$crm["Notes"]?></textarea>

</div>               


<div class="item_col">   

    <div class="content_block" style="width:100%; overflow:auto">

        <h3 style="border-bottom:1px dashed #666; margin-bottom:20px">Member details</h3>

        <div style="display:block; float:left; margin-right:5%; width:45%">

            <div style="display:block; float:left; margin-bottom:10px; clear:left">
                <h4 style="display:block; float:left; width:90px; font-size:10px;">Title</h4>
                <div style="display:block; margin-left:100px">
                    <?=$item['Title_UsersDetails']?>
                </div>
            </div>

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:90px; font-size:10px;">Forename</h4>
                <div style="display:block; margin-left:100px">
                    <?=$item['FirstName_UsersDetails']?>
                </div>
            </div>                                                        

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:90px; font-size:10px;">Surname</h4>
                <div style="display:block; margin-left:100px">
                    <?=$item['LastName_UsersDetails']?>
                </div>
            </div>
            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:90px; font-size:10px">Phone number</h4>
                <div style="display:block; margin-left:100px">
                    <?=$item['DaytimePhone_UsersDetails']?>
                </div>
            </div>

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:90px; font-size:10px">Mobile phone</h4>
                <div style="display:block; margin-left:100px">
                    <?=$item['Mobile_UsersDetails']?>
                </div>
            </div>                                     

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:90px; font-size:10px">Email</h4>
                <div style="display:block; margin-left:100px">
                    <a href="mailto:<?=$item['Email_UsersDetails']?>"><?=$item['Email_UsersDetails']?></a>
                </div>
            </div>                                                        

        </div>

        <div style="display:block; float:left;  width:50%">

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:110px; font-size:10px">Prof. Designation</h4>
                <div style="display:block; margin-left:120px">
                    <?=$item['ProfessionalDesignations']?>
                </div>
            </div>                                        

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:110px; font-size:10px;">Company Name</h4>
                <div style="display:block; margin-left:120px">
                    <?=$item['CompanyName_UsersDetails']?>
                </div>
            </div>                   

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:110px; font-size:10px;">Address</h4>
                <div style="display:block; margin-left:120px">
                    <?=nl2br($item['Address_UsersDetails'])?>
                </div>
            </div>                                                     

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:110px; font-size:10px">City</h4>
                <div style="display:block; margin-left:120px">
                    <?=$item['City_UsersDetails']?>
                </div>
            </div>                                                      

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:110px; font-size:10px">State/Province</h4>
                <div style="display:block; margin-left:120px">
                    <?=$item['State_UsersDetails']?>
                </div>
            </div>

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:110px; font-size:10px">ZIP/Postal Code</h4>
                <div style="display:block; margin-left:120px">
                    <?=$item['ZipCode_UsersDetails']?>
                </div>
            </div>

            <div style="display:block; float:left; margin-bottom:10px; clear:left;">
                <h4 style="display:block; float:left; width:110px; font-size:10px">Country</h4>
                <div style="display:block; margin-left:120px">
                    <?=$item['Country_UsersDetails']?>
                </div>
            </div>

        </div>

    </div>    
               
    <div class="content_block" style="float:left; width:45%; margin-right:5%; clear:left">
        <h3 style="border-bottom:1px dashed #666">Viewed products</h3>
        <? if (!empty($products)) { ?>
            <? foreach($products as $prod){ ?>
                <?=$prod['title']?><br />
            <? } ?> 
        <? } else { ?>
            <span style="font-size:10px">User has not viewed any products</span>
        <? } ?>
    </div>

    <div class="content_block" style="float:left; width:45%; margin-right:5%; clear:right">
        <h3 style="border-bottom:1px dashed #666">Wish lists</h3>
        <? if (!empty($wishlists)) { ?>
            <? foreach($wishlists as $list){ ?>

              <p style="margin-bottom:10px">
                <b><?=$list['name']?></b><br />

                <? foreach($list['items'] as $prod){ ?>
                    <span style="display:block; padding-left:20px;"><?=$prod['title']?></span>                    
                <? } ?> 
              </p>
                
            <? } ?> 
        <? } else { ?>
            <span style="font-size:10px">User has not created any wish lists</span>
        <? } ?>
    </div>
                             

</div>